package com.ruoyi.factory.manpower.service.impl;

import cn.hutool.core.codec.Base64;
import cn.hutool.http.HttpUtil;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.factory.manpower.domain.AttendancePersionInfo;
import com.ruoyi.factory.manpower.domain.OpenReq;
import com.ruoyi.factory.manpower.domain.OpenResp;
import com.ruoyi.factory.manpower.mapper.AttendanceMapper;
import com.ruoyi.factory.manpower.service.AttendanceService;
import com.ruoyi.factory.manpower.utils.DateUtil;
import com.ruoyi.factory.manpower.utils.OpenConstant;
import com.ruoyi.factory.manpower.utils.OpenEncryptUtil;
import com.ruoyi.factory.manpower.utils.OpenSignUtil;
import com.sun.jna.platform.unix.X11;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import nccloud.open.api.auto.token.factory.APIUtilsFactory;
import nccloud.open.api.auto.token.factory.NCCVersionEnum;
import nccloud.open.api.auto.token.itf.IAPIUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.net.URLDecoder;
import java.net.URLEncoder;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class AttendanceServiceImpl implements AttendanceService {

    protected final Logger logger = LoggerFactory.getLogger(AttendanceServiceImpl.class);

    @Value("${erp.openapi.ip}")
    private String pip;
    @Value("${erp.openapi.port}")
    private String pport;
    @Value("${erp.openapi.busi_center}")
    private String pbusi_center;
    @Value("${erp.openapi.app_id}")
    private String papp_id;
    @Value("${erp.openapi.app_secret}")
    private String papp_secret;
    @Value("${erp.openapi.public_key}")
    private String ppublic_key;
    @Value("${erp.openapi.ncc_user}")
    private String pncc_user;
    @Value("${manpower.pushtimecard}")
    private String pushtimecard;

    @Autowired
    private RedisCache redisCache;
    @Autowired
    private AttendanceMapper attendanceMapper;

    @Override
    public void attendanceAccess() {
        try {
            //判断开关状态
            if("Y".equals(pushtimecard)){
                sendAccess();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public void attendanceAccess2(String param) {
        try {
            JSONObject jsonObject = JSONObject.fromObject(param);
            String s = jsonObject.optString("starttime");
            String e = jsonObject.optString("endTime");
            for (int i = 12; i < 14; i++) {
                String format = String.format("%02d", i);
                s = "2025-11-"+format+" 00:00:01";
                e = "2025-11-"+format+" 23:59:59";
                sendAccess2(s,e);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void sendAccess2(String starttime, String endTime) throws Exception {
        //加密秘钥  由一卡通系统生成
        String key = "9663a228f5a94137b4faafd009b70346";
        //签名秘钥  由一卡通系统生成
        String signKey = "e7f26fdbcdb245548fb90dddc74b4c5d";
        OpenReq openReq = new OpenReq();
        //应用ID
        openReq.setAppid("00000000000101");
        //机构编码，一卡通系统分配
        openReq.setDpcode("00000000");
        //请求日期，YYYYMMddHHmmss
        openReq.setCtdate(DateUtil.dateToString(new Date(), "yyyyMMddHHmmss"));
        //消息ID，每次请求保证唯一，建议用UUID
        openReq.setMsgid(UUID.randomUUID().toString());

        //业务参数，json格式字符串    余额信息查询接口
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("idserial", "000499");
        jsonObject.put("count", 20);
        jsonObject.put("ver", 0);
        jsonObject.put("ispage", "False");
        jsonObject.put("extendid", "50001,50002,50003,50004,50005,50006,50015,50016,50017,50018");
        //设置查询时间
        jsonObject.put("startdate", starttime);
        jsonObject.put("enddate", endTime);


//        jsonObject.put("pagesize", 100);
//        jsonObject.put("pageno", 1);
        try {
            logger.info("园区管理查询请求"+jsonObject.toString());
            openReq.setData(encryt(jsonObject.toString(), key));
        } catch (Exception e) {
            e.printStackTrace();
        }
        String url = "http://192.168.0.201/IdentityWebService/Identity.ThirdOpenApiCall.ashx/group/GetRecordInfo";

        //对参数进行签名
        String sign = OpenSignUtil.sha256Sign(openReq.toStringMap(), signKey);

        openReq.setSign(sign);

        /*String url = "http://127.0.0.1:8080/escp-api/open/v1/dept/list";*/
        String jsonBody = openReq.toString();
//        System.out.println("请求地址：" + url);
//        System.out.println("请求参数：" + jsonBody);
        String result = HttpUtil.createPost(url).body(jsonBody).execute().body();
//        System.out.println("获得返回的结果：" + result);
        //对接过进行验签
        OpenResp openResp = OpenResp.toBean(result, OpenResp.class);
        if (openResp.getRetcode() != 200) {
            logger.info(openResp.getRetmsg());
            return;
        }
        if (!checkSign(openResp, signKey)) {
            logger.info("园区管理验签失败！");
        }
        //对参数进行解密
        String data = decrypt(openResp.getData(), key);
        logger.info("园区管理查询结果解密！"+ data);
        JSONObject jsonObject1 = JSONObject.fromObject(data);

        String data2 = jsonObject1.optString("data");

        if(!"null".equals(data2)){
            JSONObject data1 = JSONObject.fromObject(data2);
            String s = data1.toString();
            JSONArray jsonArray = data1.optJSONArray("Table");
            for (Object o : jsonArray) {
                JSONObject jsonObject2 = JSONObject.fromObject(o);
                //人员编码
                String s1 = jsonObject2.optString("OUTID");
                //打卡时间
                String s2 = jsonObject2.optString("OPERTIME");
//                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss");
//                Date parse = sdf2.parse(s2);
                String replace = s2.replace("T", " ");
//                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                Date parse = sdf3.parse(replace);
//                String format1 = sdf3.format(parse);
                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date parse = sdf3.parse(replace);
                String format1 = sdf3.format(parse);
                format1 = format1+":00";

                JSONObject param = new JSONObject();
                AttendancePersionInfo psi = new AttendancePersionInfo();
                psi.setCode(s1);
                psi.setSigntime(format1);
                List<AttendancePersionInfo> attendancePersionInfos = attendanceMapper.selectAttendancePersionInfoList(psi);
                if(attendancePersionInfos.isEmpty()){
                    List<AttendancePersionInfo> attendancePersionInfos1 = attendanceMapper.selectpersionInfoList(psi);
                    if(!attendancePersionInfos1.isEmpty()){
                        AttendancePersionInfo attendancePersionInfo = attendancePersionInfos1.get(0);
                        String pkpsndoc = attendancePersionInfo.getPkpsndoc();
                        param.put("staffCode",pkpsndoc);
                        param.put("signtime",format1);
                        param.put("placeName","瑞丰新材");
                        param.put("addressDetail","河南省新乡市新乡县大召营镇新乡市瑞丰新材料股份有限公司");
                        param.put("usercode","000009");
                        String pushtoerp = pushtoerp(param.toString(),s1);
                    }
                }
            }
        }
    }

    public void sendAccess() throws Exception {

        //设置查询时间
        Date date = new Date();
        long time = date.getTime();
        long l = time - (1000 * 60 * 60);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(date);
        String format2 = sdf.format(l);
        String mjsdater = (String)redisCache.getCacheObject("mjsdate");
        String sdate = "";
        if(StringUtils.isNotBlank(mjsdater) && mjsdater.contains("-")){
            sdate = mjsdater;
        }else{
            sdate = format2;
        }
        redisCache.setCacheObject("mjsdate",format);
        String sqltxt = "select * from id_recordnew where uploadtime >= ?";
        Connection connection = null;
        Statement statement = null;
        ResultSet rSet = null;
        PreparedStatement pstmt = null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            DriverManager.setLoginTimeout(60);
            connection = DriverManager.getConnection("jdbc:mysql://192.168.0.186:3306/escp_lqiu","rfsystem","Rf369.qwe@");
            pstmt  = connection.prepareStatement(sqltxt);
            pstmt.setString(1, sdate);
            rSet = pstmt.executeQuery();//实现更新，增删改

            while(rSet.next()){
                //人员编码
                String s1 = rSet.getString("OUTID");
                //打卡时间
                String s2 = rSet.getString("OPERTIME");

                JSONObject param = new JSONObject();
                AttendancePersionInfo psi = new AttendancePersionInfo();
                psi.setCode(s1);
                psi.setSigntime(s2);
                List<AttendancePersionInfo> attendancePersionInfos = attendanceMapper.selectAttendancePersionInfoList(psi);
                if(attendancePersionInfos.isEmpty()){
                    List<AttendancePersionInfo> attendancePersionInfos1 = attendanceMapper.selectpersionInfoList(psi);
                    if(!attendancePersionInfos1.isEmpty()){
                        AttendancePersionInfo attendancePersionInfo = attendancePersionInfos1.get(0);
                        String pkpsndoc = attendancePersionInfo.getPkpsndoc();
                        param.put("staffCode",pkpsndoc);
                        param.put("signtime",s2);
                        param.put("placeName","瑞丰新材");
                        param.put("addressDetail","河南省新乡市新乡县大召营镇新乡市瑞丰新材料股份有限公司");
                        param.put("usercode","000009");
                        String pushtoerp = pushtoerp(param.toString(),s1);
                    }
                }
            }
        }
        catch(Exception e){
            e.printStackTrace();
        }
        finally {
            try {
                rSet.close();
            } catch (Exception e2) {
            }
            try {
                statement.close();
            } catch (Exception e3) {
            }
            try {
                connection.close();
            } catch (Exception e4) {
            }
            try {
                pstmt.close();
            } catch (Exception e5) {
            }
        }




//        //加密秘钥  由一卡通系统生成
//        String key = "9663a228f5a94137b4faafd009b70346";
//        //签名秘钥  由一卡通系统生成
//        String signKey = "e7f26fdbcdb245548fb90dddc74b4c5d";
//        OpenReq openReq = new OpenReq();
//        //应用ID
//        openReq.setAppid("00000000000101");
//        //机构编码，一卡通系统分配
//        openReq.setDpcode("00000000");
//        //请求日期，YYYYMMddHHmmss
//        openReq.setCtdate(DateUtil.dateToString(new Date(), "yyyyMMddHHmmss"));
//        //消息ID，每次请求保证唯一，建议用UUID
//        openReq.setMsgid(UUID.randomUUID().toString());
//
//        //业务参数，json格式字符串    余额信息查询接口
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("idserial", "000499");
//        jsonObject.put("count", 20);
//        jsonObject.put("ver", 0);
//        jsonObject.put("ispage", "False");
//        jsonObject.put("extendid", "50001,50002,50003,50004,50005,50006,50015,50016,50017,50018");
//        //设置查询时间
//        Date date = new Date();
//        long time = date.getTime();
//        long l = time - (1000 * 60 * 60);
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String format = sdf.format(date);
//        String format2 = sdf.format(l);
//
//        String mjsdater = (String)redisCache.getCacheObject("mjsdate");
//        if(StringUtils.isNotBlank(mjsdater) && mjsdater.contains("-")){
//            jsonObject.put("startdate", mjsdater);
//        }else{
//            jsonObject.put("startdate", format2);
//        }
//        redisCache.setCacheObject("mjsdate",format);
//        jsonObject.put("enddate", format);
//
//
////        jsonObject.put("pagesize", 100);
////        jsonObject.put("pageno", 1);
//        try {
//            openReq.setData(encryt(jsonObject.toString(), key));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        String url = "http://192.168.0.201/IdentityWebService/Identity.ThirdOpenApiCall.ashx/group/GetRecordInfo";
//
//        //对参数进行签名
//        String sign = OpenSignUtil.sha256Sign(openReq.toStringMap(), signKey);
//
//        openReq.setSign(sign);
//
//        /*String url = "http://127.0.0.1:8080/escp-api/open/v1/dept/list";*/
//        String jsonBody = openReq.toString();
////        System.out.println("请求地址：" + url);
////        System.out.println("请求参数：" + jsonBody);
//        String result = HttpUtil.createPost(url).body(jsonBody).execute().body();
////        System.out.println("获得返回的结果：" + result);
//        //对接过进行验签
//        OpenResp openResp = OpenResp.toBean(result, OpenResp.class);
//        if (openResp.getRetcode() != 200) {
//            logger.info(openResp.getRetmsg());
//            return;
//        }
//        if (!checkSign(openResp, signKey)) {
//            logger.info("园区管理验签失败！");
//        }
//        //对参数进行解密
//        String data = decrypt(openResp.getData(), key);
//        logger.info("园区管理查询结果解密！"+ data);
//        JSONObject jsonObject1 = JSONObject.fromObject(data);
//
//        String data2 = jsonObject1.optString("data");
//
//        if(!"null".equals(data2)){
//            JSONObject data1 = JSONObject.fromObject(data2);
//            String s = data1.toString();
//            JSONArray jsonArray = data1.optJSONArray("Table");
//            for (Object o : jsonArray) {
//                JSONObject jsonObject2 = JSONObject.fromObject(o);
//                //人员编码
//                String s1 = jsonObject2.optString("OUTID");
//                //打卡时间
//                String s2 = jsonObject2.optString("OPERTIME");
////                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss");
////                Date parse = sdf2.parse(s2);
//                String replace = s2.replace("T", " ");
////                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
////                Date parse = sdf3.parse(replace);
////                String format1 = sdf3.format(parse);
//                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
//                Date parse = sdf3.parse(replace);
//                String format1 = sdf3.format(parse);
//                format1 = format1+":00";
//
//                JSONObject param = new JSONObject();
//                AttendancePersionInfo psi = new AttendancePersionInfo();
//                psi.setCode(s1);
//                psi.setSigntime(format1);
//                List<AttendancePersionInfo> attendancePersionInfos = attendanceMapper.selectAttendancePersionInfoList(psi);
//                if(attendancePersionInfos.isEmpty()){
//                    List<AttendancePersionInfo> attendancePersionInfos1 = attendanceMapper.selectpersionInfoList(psi);
//                    if(!attendancePersionInfos1.isEmpty()){
//                        AttendancePersionInfo attendancePersionInfo = attendancePersionInfos1.get(0);
//                        String pkpsndoc = attendancePersionInfo.getPkpsndoc();
//                        param.put("staffCode",pkpsndoc);
//                        param.put("signtime",format1);
//                        param.put("placeName","瑞丰新材");
//                        param.put("addressDetail","河南省新乡市新乡县大召营镇新乡市瑞丰新材料股份有限公司");
//                        param.put("usercode","000009");
//                        String pushtoerp = pushtoerp(param.toString(),s1);
//                    }
//                }
//            }
//        }

    }

    public void sendAccess2() throws Exception {
        //加密秘钥  由一卡通系统生成
        String key = "9663a228f5a94137b4faafd009b70346";
        //签名秘钥  由一卡通系统生成
        String signKey = "e7f26fdbcdb245548fb90dddc74b4c5d";
        OpenReq openReq = new OpenReq();
        //应用ID
        openReq.setAppid("00000000000101");
        //机构编码，一卡通系统分配
        openReq.setDpcode("00000000");
        //请求日期，YYYYMMddHHmmss
        openReq.setCtdate(DateUtil.dateToString(new Date(), "yyyyMMddHHmmss"));
        //消息ID，每次请求保证唯一，建议用UUID
        openReq.setMsgid(UUID.randomUUID().toString());

        //业务参数，json格式字符串    余额信息查询接口
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("idserial", "000499");
        jsonObject.put("count", 20);
        jsonObject.put("ver", 0);
        jsonObject.put("ispage", "False");
        jsonObject.put("extendid", "50001,50002,50003,50004,50005,50006,50015,50016,50017,50018");
        //设置查询时间
        Calendar instance = Calendar.getInstance();
        instance.add(Calendar.DATE,-2);
        Date date = instance.getTime();
        long time = date.getTime();
        long l = time - (1000 * 60 * 60);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(date);
        String format2 = sdf.format(l);

        String mjsdater = (String)redisCache.getCacheObject("mjsdateyesterday");
        if(StringUtils.isNotBlank(mjsdater) && mjsdater.contains("-")){
            jsonObject.put("startdate", mjsdater);
        }else{
            jsonObject.put("startdate", format2);
        }
        redisCache.setCacheObject("mjsdateyesterday",format);
        jsonObject.put("enddate", format);


//        jsonObject.put("pagesize", 100);
//        jsonObject.put("pageno", 1);
        try {
            openReq.setData(encryt(jsonObject.toString(), key));
        } catch (Exception e) {
            e.printStackTrace();
        }
        String url = "http://192.168.0.201/IdentityWebService/Identity.ThirdOpenApiCall.ashx/group/GetRecordInfo";

        //对参数进行签名
        String sign = OpenSignUtil.sha256Sign(openReq.toStringMap(), signKey);

        openReq.setSign(sign);

        /*String url = "http://127.0.0.1:8080/escp-api/open/v1/dept/list";*/
        String jsonBody = openReq.toString();
//        System.out.println("请求地址：" + url);
//        System.out.println("请求参数：" + jsonBody);
        String result = HttpUtil.createPost(url).body(jsonBody).execute().body();
//        System.out.println("获得返回的结果：" + result);
        //对接过进行验签
        OpenResp openResp = OpenResp.toBean(result, OpenResp.class);
        if (openResp.getRetcode() != 200) {
            logger.info(openResp.getRetmsg());
            return;
        }
        if (!checkSign(openResp, signKey)) {
            logger.info("2园区管理验签失败！");
        }
        //对参数进行解密
        String data = decrypt(openResp.getData(), key);
        logger.info("2园区管理查询结果解密！"+ data);
        JSONObject jsonObject1 = JSONObject.fromObject(data);

        String data2 = jsonObject1.optString("data");

        if(!"null".equals(data2)){
            JSONObject data1 = JSONObject.fromObject(data2);
            String s = data1.toString();
            JSONArray jsonArray = data1.optJSONArray("Table");
            for (Object o : jsonArray) {
                JSONObject jsonObject2 = JSONObject.fromObject(o);
                //人员编码
                String s1 = jsonObject2.optString("OUTID");
                //打卡时间
                String s2 = jsonObject2.optString("OPERTIME");
                //上传记录时间
                String s3 = jsonObject2.optString("uploadtime");
//                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss");
//                Date parse = sdf2.parse(s2);
                String replace = s2.replace("T", " ");
                String replace2 = s3.replace("T", " ");
//                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                Date parse = sdf3.parse(replace);
//                String format1 = sdf3.format(parse);
                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date parse = sdf3.parse(replace);
                Date parse2 = sdf3.parse(replace2);
                String format1 = sdf3.format(parse);
                String format3 = sdf3.format(parse2);
                format1 = format1+":00";
                format3 = format3+":00";

                if(format1.equals(format3)){
                    return;
                }
                JSONObject param = new JSONObject();
                AttendancePersionInfo psi = new AttendancePersionInfo();
                psi.setCode(s1);
                psi.setSigntime(format1);
                List<AttendancePersionInfo> attendancePersionInfos = attendanceMapper.selectAttendancePersionInfoList(psi);
                if(attendancePersionInfos.isEmpty()){
                    List<AttendancePersionInfo> attendancePersionInfos1 = attendanceMapper.selectpersionInfoList(psi);
                    if(!attendancePersionInfos1.isEmpty()){
                        AttendancePersionInfo attendancePersionInfo = attendancePersionInfos1.get(0);
                        String pkpsndoc = attendancePersionInfo.getPkpsndoc();
                        param.put("staffCode",pkpsndoc);
                        param.put("signtime",format1);
                        param.put("placeName","瑞丰新材");
                        param.put("addressDetail","河南省新乡市新乡县大召营镇新乡市瑞丰新材料股份有限公司");
                        param.put("usercode","000009");
                        String pushtoerp = pushtoerp(param.toString(),s1);
                    }
                }
            }
        }
    }
    //对参数进行加密 slj
    private String encryt(String data, String key) throws Exception {
        //获得对称密钥
        byte[] desKey = Base64.decode(key);
        //对数据进行加密处理
        String cipherString = OpenEncryptUtil.desEncrypt(data, desKey);
        //对加密的数据进行url编码处理
        cipherString = URLEncoder.encode(cipherString, OpenConstant.CHARSET);
        return cipherString;
    }

    //对参数进行验签
    private boolean checkSign(OpenResp openResp, String signKey) throws Exception {
        boolean checkResult = false;
        //验签
        String sign = URLDecoder.decode(openResp.getSign(), "UTF-8");
        checkResult = OpenSignUtil.sha256CheckSign(openResp.toStringMap(), sign, signKey);
        return checkResult;
    }

    //对参数进行解密
    private String decrypt(String data, String key) throws Exception {
        //对数据进行URL解码
        data = URLDecoder.decode(data, OpenConstant.CHARSET);
        //获得对称密钥
        byte[] desKey = Base64.decode(key);
        String result = OpenEncryptUtil.desDecrypt(data, desKey);
        return result;
    }


    public String pushtoerp(String param,String usercode){

        IAPIUtils util = null;

        util = APIUtilsFactory.getAPIUtils(NCCVersionEnum.NCC2111);
        // 服务地址ip

        String ip = pip;
        String port = pport;

        // 账套编码，开发环境使用develop，生产环境需要使用用root账号登录，在“系统管理”节点查看账套编码
        String busi_center = pbusi_center;
        // 第三方应用编码

        String app_id = papp_id;

        String app_secret = papp_secret;

        // 公钥，加解密使用
        String public_key = ppublic_key;
        // ncc用户名
        String ncc_user = pncc_user;
        // ncc用户密码
        String password = "";
        // 公有云租户id
        String tenant_id = null;
        // 加密等级
        String secret_level = "L0";
        // 授权模式，客户端模式为client，密码模式为：password
        String grant_type = "client";
        util.init(ip, port, busi_center, app_id, app_secret, public_key, ncc_user, password);
        String token = null;
        try {
            token = util.getToken();
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 请求的OpenAPI接口地址，注意nccloud前面没有"/ nccloud/api/nccloud/api/uapbd/psndocmanage/psndoc/add"
        String apiuri = "nccloud/api/hrkq/insertRecordljj/saveRecordl";
        util.setApiUrl(apiuri);
        // 对应接口地址的请求参数
        // 携带token访问接口，获取结果
        String rell = "N";
        for (int i = 0; i < 5; i++) {
            if("Y".equals(rell)) continue;;
            logger.info(usercode+"请求erp考勤打卡新增接口入参: "+param);
            // 携带token访问接口，获取结果
            String result = null;
            try {
                result = util.getAPIRetrun(token, param);
            } catch (Exception e) {
                e.printStackTrace();
            }
            logger.info("请求erp考勤打卡新增接口返回参数: "+result);
            if(StringUtils.isNotBlank(result)){
                JSONObject jsonObject = null;
                try {
                    jsonObject = JSONObject.fromObject(result);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if(null != jsonObject){
                    String s = jsonObject.optString("code");
                    if(StringUtils.isNotBlank(s) && "200".equals(s)){
                        rell = "Y";
                    }
                }

            }
        }

        return null;
    }
}
